package com.tsinjie.metadata.java.model;

import java.io.Serializable;
import java.util.List;

/**
 * Created by LiuXunming on 2015-10-14.
 * java类字段
 */
public class JavaField implements Serializable {
    /**
     * 字段名
     */
    protected String name;
    /**
     * 字段注释
     */
    protected String remark;
    /**
     * 变量类型
     */
    protected String type;
    /**
     * JDBC类型
     */
    protected String jdbcType;
    /**
     * 数据库表字段名称
     */
    protected String fieldName;
    /**
     * 字段长度
     */
    protected Integer length;
    /**
     * 是否允许空
     */
    protected boolean nullable;
    /**
     * 默认值
     */
    protected Object defaultValue;
    /**
     * 类所在模块，可以为空
     */
    protected String classModule;
    /**
     * html显示类型
     * value: 'hide', text: '隐藏域'},
     * {value: 'text', text: '文本'},
     * {value: 'date', text: '时间'},
     * {value: 'number', text: '数字'},
     * {value: 'select', text: '下拉框'},
     * {value: 'radio', text: '单选按钮'},
     * {value: 'checkbox', text: '复选按钮'},
     * {value: 'textarea', text: '文本域'}
     */
    protected String htmlShowType;
    /**
     * 可选值
     */
    protected List<JavaFieldValue> javaFieldValues;

    public JavaField() {
        this.htmlShowType = "text";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getJdbcType() {
        return jdbcType;
    }

    public void setJdbcType(String jdbcType) {
        this.jdbcType = jdbcType;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public boolean isNullable() {
        return nullable;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
    }

    public List<JavaFieldValue> getJavaFieldValues() {
        return javaFieldValues;
    }

    public void setJavaFieldValues(List<JavaFieldValue> javaFieldValues) {
        this.javaFieldValues = javaFieldValues;
    }

    public String getClassModule() {
        return classModule;
    }

    public void setClassModule(String classModule) {
        this.classModule = classModule;
    }

    public String getHtmlShowType() {
        return htmlShowType;
    }

    public void setHtmlShowType(String htmlShowType) {
        this.htmlShowType = htmlShowType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof JavaField)) return false;

        JavaField javaField = (JavaField) o;

        if (fieldName != null ? !fieldName.equals(javaField.fieldName) : javaField.fieldName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return fieldName != null ? fieldName.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "JavaField{" +
                "name='" + name + '\'' +
                ", remark='" + remark + '\'' +
                ", type='" + type + '\'' +
                ", jdbcType='" + jdbcType + '\'' +
                ", fieldName='" + fieldName + '\'' +
                ", length=" + length + '\'' +
                ", nullable=" + nullable + '\'' +
                ", defaultValue=" + defaultValue + '\'' +
                ", classModule=" + classModule + '\'' +
                ", htmlShowType='" + htmlShowType + '\'' +
                ", javaFieldValues=" + javaFieldValues +
                '}';
    }
}
